using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class SkeletonGroundState : SkeletonStateBase
{
    public SkeletonGroundState(ControllerBase controller, StateMachineBase stateMachine, string stateName, 
        string animatorParameter = null) : base(controller, stateMachine, stateName, animatorParameter)
    {
    }

    private Transform target;
    public override void Enter()
    {
        base.Enter();

        target =  PlayerManager.Instance.controller.transform;
    }
    
    public override void Update()
    {
        base.Update();

        if (SelfController.isFindTarget
            ||Vector2.Distance(target.position, SelfController.transform.position) < 2)//如果找到目标或者距离小于2，则切换到战斗状态
        {
            stateMachine.ChangeState(Setting.battle);
        }
    }
}
